package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertRuleDto;
import com.zzyl.dto.DeviceDto;
import com.zzyl.service.DeviceService;
import com.zzyl.vo.ProductVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description DeviceController
 * @Author jiangweicong
 * @Date 2025-05-19  18:13
 */
@RestController
@RequestMapping("/iot")
@Api(tags = "管理端 - 物联网iot相关接口")
public class DeviceController extends BaseController{
    @Autowired
    private DeviceService deviceService;


    @PostMapping("/syncProductList")
    @ApiOperation(value = "从物联网平台同步产品列表")
    public ResponseResult syncProductList(){
        deviceService.syncProductList();
        return ResponseResult.success();
    }
    @GetMapping("/allProduct")
    @ApiOperation(value = "查询所有产品")
    public ResponseResult<List<ProductVo>>  allProduct(){
        deviceService.allProduct();
        return ResponseResult.success();
    }

    @PostMapping("/RegisterDevice")
    @ApiOperation(value = "注册设备")
    public ResponseResult RegisterDevice(@RequestBody DeviceDto deviceDto){
        deviceService.RegisterDevice(deviceDto);
        return ResponseResult.success();
    }
}
